<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="keyword" content="">

    <title>基础文件 - BIM管理</title>

    <!-- Bootstrap core CSS -->
    <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="__PUBLIC__/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="__PUBLIC__/css/style.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style-responsive.css" rel="stylesheet" />
    <!-- new styles-->
      <link href="__PUBLIC__/css/xxxstyle.css" rel="stylesheet" />

      <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

  <section id="container" class="">
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper site-min-height">
              <!-- page start-->
              <section class="panel">
                  <header class="panel-heading"><i class="icon-folder-close"></i>基础文件
                      {$name}
                      <span class="pull-right">
                        <if condition="$_SESSION['pid'] neq ''"> <button type="button" class="btn btn-submit btn-xs" data-toggle="modal" href="#add_file"><i class="icon-plus"></i>添加文件夹</button></if>
                      </span>
                  </header>
                  
                  <table class="table table-hover p-table">
                      <thead>
                      <tr>
                          <th>文件名</th>
                          <th>修改日期</th>
                          <th>操作</th>
                      </tr>
                      </thead>
	                    <tbody>
    	                    <?php if(empty($file)) {?>  
    	                       <tr><td style="text-align: center;" colspan="5">查询不到相关数据</td></tr>
    	                    <?php }?>    
  	                      <foreach name="file" item="v" key="k">
  	                          <tr>
  	                              <td>
  	                                  <span class="fileStyle fileStyle-folder"></span>
  	                                  <a href="{:U('Bim/gover',array('fid'=>$v['id']))}">{$v.name}</a>
  	                              </td>
  	                              <td>{$v.add_time|date='Y-m-d H:i',###}</td>
                                  <td></td>
  	                              <!-- <td>
  	                            	    <span class="btn btn-primary btn-xs" style="cursor:pointer;" onclick="edit('{$v.name}',{$v.id})"><i class="glyphicon glyphicon-edit"></i>重命名</span>
  	                                  <span class="btn btn-danger btn-xs" onclick="add_file({$v.id})"><i class="icon-trash"></i>删除</span>
  	                              </td> -->
  	                          </tr>
  	                      </foreach>
	                    </tbody>
                  </table>
              </section>
              <div class="row">
              	  <div class="col-xs-12 text-center">{$page}</div>		
              </div>
              <!-- page end-->
          </section>
          <!-- modal -->
      </section>
      <!--main content end-->
  </section>
  		<!--新建文件夹（Modal） -->
	        <div class="modal fade" id="add_file" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
              <div class="modal-dialog">
                  <div class="modal-content">
                      <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                          <h4 class="modal-title">新增文件夹</h4>
                      </div>
                          <div class="modal-body">
                           <div class="form-group">
                              <label class="col-sm-3 control-label">文件夹名称</label>
                              <div class="col-sm-9">
                                  <input type="text" class="form-control" value="" name="name" maxlength="8" onblur="this.value=this.value.replace(/[^\u4e00-\u9fa5]/g,'')">
                              </div>
                          </div>
                         </div>
                      <div class="modal-footer">
                          <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                          <button class="btn btn-submit" type="button" onclick="add_file()">添加</button>
                      </div>
                  </div>
              </div>
          </div>
           <!--编辑文件夹（Modal） -->
	        <div class="modal fade" id="edit_file" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
              <div class="modal-dialog">
                  <div class="modal-content">
                      <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                          <h4 class="modal-title">重命名</h4>
                      </div>
                          <div class="modal-body">
                           <div class="form-group">
                              <label class="col-sm-3 control-label">新的文件夹名称</label>
                              <div class="col-sm-9">
                                  <input type="text" class="form-control" value="" name="bname" maxlength="4" onblur="this.value=this.value.replace(/[^\u4e00-\u9fa5]/g,'')">
                                  <input type="hidden" class="form-control" value="" name="id">
                              </div>
                          </div>
                         </div>
                      <div class="modal-footer">
                          <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                          <button class="btn btn-submit" type="button" onclick="editfile()">修改</button>
                      </div>
                  </div>
              </div>
          </div>
  
    <!-- js placed at the end of the document so the pages load faster -->
    <script src="__PUBLIC__/js/jquery.js"></script>
    <script src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
    <script src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script class="include" type="text/javascript" src="__PUBLIC__/js/jquery.dcjqaccordion.2.7.js"></script>
    <script src="__PUBLIC__/js/jquery.scrollTo.min.js"></script>
    <script src="__PUBLIC__/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="__PUBLIC__/js/jquery.customSelect.min.js" ></script>
    <!--common script for all pages-->
    <script src="__PUBLIC__/js/common-scripts.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>
    <script>
	    function add_file(id=0){
	    	if(id == 0){
	    		 var name = $("input[name='name']").val();
		    	 if(name==''){
	       		  layer.msg('文件夹名不能为空',{icon:2});
	       		  return;
	       	 	 }
	    	}
	    	 $.ajax({
 		 		type : 'post',
 		 		url : '__URL__/add_file',
 		 		data : {name:name,id:id},
 		 		dataType : 'json',
 		 		success : function(res){
 		 			 if(res.status==0){
							layer.alert(res.info, {icon: 2});
							return;
						 }
 		 			 if(!res.errNo){
 		 				 layer.msg(res.msg,{icon:1});
 		 				 setTimeout("location.reload()",2000);
 			          }else{
 			        	 layer.msg(res.msg,{icon:2});
 			          }
 		 		}
 		     })
	    	 
	    }
	    
	    function edit(o,id){
	    	$("input[name='bname']").attr('value',o);
	    	$("input[name='id']").attr('value',id);
	    	$('#edit_file').modal('show');
	    }
	    function editfile(){
	    	var name = $("input[name='bname']").val();
	    	var id = $("input[name='id']").val();
	    	 if(name==''){
	       		  layer.msg('文件夹名不能为空',{icon:2});
	       		  return;
	       	 	 }
	    	 if(!id){
	       		  layer.msg('id出现错误',{icon:2});
	       		  return;
	       	 	 }
	     	 $.ajax({
	 		 		type : 'post',
	 		 		url : '__URL__/editfile',
	 		 		data : {name:name,id:id},
	 		 		dataType : 'json',
	 		 		success : function(res){
	 		 			 if(res.status==0){
								layer.alert(res.info, {icon: 2});
								return;
							 }
	 		 			 if(!res.errNo){
	 		 				 layer.msg(res.msg,{icon:1});
	 		 				 setTimeout("location.reload()",2000);
	 			          }else{
	 			        	 layer.msg(res.msg,{icon:2});
	 			          }
	 		 		}
	 		     })
	    }
    </script>
  </body>
</html>
